home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mtc / mtcsetup.frm < prev    next >
Text File  |  1995-05-02  |  8KB  |  276 lines

  1. VERSION 2.00
  2. Begin Form MidiForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "MIDI Setup"
  6.    ClientHeight    =   2730
  7.    ClientLeft      =   2295
  8.    ClientTop       =   2505
  9.    ClientWidth     =   4230
  10.    ControlBox      =   0   'False
  11.    Height          =   3135
  12.    Left            =   2235
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2730
  17.    ScaleWidth      =   4230
  18.    Top             =   2160
  19.    Width           =   4350
  20.    Begin SSPanel Z 
  21.       AutoSize        =   3  'AutoSize Child To Panel
  22.       BackColor       =   &H00C0C0C0&
  23.       BevelInner      =   1  'Inset
  24.       BevelOuter      =   0  'None
  25.       BevelWidth      =   3
  26.       BorderWidth     =   0
  27.       Font3D          =   0  'None
  28.       ForeColor       =   &H00FF0000&
  29.       Height          =   555
  30.       Index           =   10
  31.       Left            =   1530
  32.       TabIndex        =   2
  33.       Top             =   2010
  34.       Width           =   1095
  35.       Begin SSCommand cmdOK 
  36.          BevelWidth      =   3
  37.          Caption         =   "&OK"
  38.          Font3D          =   0  'None
  39.          ForeColor       =   &H00FF0000&
  40.          Height          =   465
  41.          Left            =   45
  42.          Outline         =   0   'False
  43.          TabIndex        =   3
  44.          Top             =   45
  45.          Width           =   1005
  46.       End
  47.    End
  48.    Begin SSPanel Z 
  49.       Alignment       =   6  'Center - TOP
  50.       BackColor       =   &H00C0C0C0&
  51.       BevelInner      =   2  'Raised
  52.       BevelOuter      =   0  'None
  53.       BevelWidth      =   2
  54.       BorderWidth     =   0
  55.       Caption         =   "MIDI Out Device"
  56.       Font3D          =   3  'Inset w/light shading
  57.       FontBold        =   -1  'True
  58.       FontItalic      =   0   'False
  59.       FontName        =   "MS Sans Serif"
  60.       FontSize        =   9.75
  61.       FontStrikethru  =   0   'False
  62.       FontUnderline   =   0   'False
  63.       ForeColor       =   &H00FF0000&
  64.       Height          =   795
  65.       Index           =   1
  66.       Left            =   150
  67.       TabIndex        =   1
  68.       Top             =   1050
  69.       Width           =   3915
  70.       Begin SSPanel Z 
  71.          Alignment       =   6  'Center - TOP
  72.          AutoSize        =   3  'AutoSize Child To Panel
  73.          BackColor       =   &H00C0C0C0&
  74.          BevelInner      =   1  'Inset
  75.          BevelOuter      =   0  'None
  76.          BevelWidth      =   2
  77.          BorderWidth     =   0
  78.          Font3D          =   3  'Inset w/light shading
  79.          ForeColor       =   &H00FF0000&
  80.          Height          =   360
  81.          Index           =   3
  82.          Left            =   120
  83.          TabIndex        =   6
  84.          Top             =   300
  85.          Width           =   3645
  86.          Begin ComboBox OutList 
  87.             Height          =   300
  88.             Left            =   30
  89.             Style           =   2  'Dropdown List
  90.             TabIndex        =   7
  91.             TabStop         =   0   'False
  92.             Top             =   30
  93.             Width           =   3585
  94.          End
  95.       End
  96.    End
  97.    Begin SSPanel Z 
  98.       Alignment       =   6  'Center - TOP
  99.       BackColor       =   &H00C0C0C0&
  100.       BevelInner      =   2  'Raised
  101.       BevelOuter      =   0  'None
  102.       BevelWidth      =   2
  103.       BorderWidth     =   0
  104.       Caption         =   "MIDI In Device"
  105.       Font3D          =   3  'Inset w/light shading
  106.       FontBold        =   -1  'True
  107.       FontItalic      =   0   'False
  108.       FontName        =   "MS Sans Serif"
  109.       FontSize        =   9.75
  110.       FontStrikethru  =   0   'False
  111.       FontUnderline   =   0   'False
  112.       ForeColor       =   &H00FF0000&
  113.       Height          =   765
  114.       Index           =   0
  115.       Left            =   150
  116.       TabIndex        =   0
  117.       Top             =   150
  118.       Width           =   3915
  119.       Begin SSPanel Z 
  120.          Alignment       =   6  'Center - TOP
  121.          AutoSize        =   3  'AutoSize Child To Panel
  122.          BackColor       =   &H00C0C0C0&
  123.          BevelInner      =   1  'Inset
  124.          BevelOuter      =   0  'None
  125.          BevelWidth      =   2
  126.          BorderWidth     =   0
  127.          Font3D          =   3  'Inset w/light shading
  128.          ForeColor       =   &H00FF0000&
  129.          Height          =   360
  130.          Index           =   2
  131.          Left            =   120
  132.          TabIndex        =   4
  133.          Top             =   300
  134.          Width           =   3645
  135.          Begin ComboBox InList 
  136.             Height          =   300
  137.             Left            =   30
  138.             Style           =   2  'Dropdown List
  139.             TabIndex        =   5
  140.             TabStop         =   0   'False
  141.             Top             =   30
  142.             Width           =   3585
  143.          End
  144.       End
  145.    End
  146. End
  147. Option Explicit
  148.  
  149. Sub CmdOK_Click ()
  150.     Midi_SaveIni
  151.     Hide
  152. End Sub
  153.  
  154. Sub Form_Activate ()
  155.     Midi_LoadIni
  156. End Sub
  157.  
  158. Sub Form_Load ()
  159.      Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
  160. End Sub
  161.  
  162. Sub InList_Click ()
  163.     If InList.ListIndex > -1 Then
  164.         InDevice = InList.ListIndex
  165.         MidiIn_Open (InDevice)
  166.     End If
  167. End Sub
  168.  
  169. Sub Midi_LoadIni ()
  170.     Dim FileData, Msg As String, ap As String
  171.     Dim Fnum, ii, jj
  172.  
  173.     On Error GoTo Midi_LoadIniError
  174.  
  175.     Fnum = FreeFile     'MTC.INI ha d'estar
  176.                         'al mateix directori que l'aplicaci≤
  177.  
  178.     ap = App.Path
  179.     If Right$(ap, 1) <> "\" Then ap = ap & "\"
  180.     Open ap & "MTC.INI" For Input As Fnum
  181.  
  182.     jj = 1
  183.     Do While Not EOF(Fnum)
  184.         Line Input #Fnum, FileData
  185.         If Left$(FileData, 1) = "*" Then
  186.             ii = Mid$(FileData, 2)
  187.             Select Case jj
  188.                 Case 1
  189.                     OutDevice = Val(ii)
  190.                     If MidiForm.OutList.ListCount > OutDevice + 1 Then
  191.                         MidiForm.OutList.ListIndex = OutDevice + 1
  192.                     Else
  193.                         OutDevice = -2
  194.                         MidiForm.OutList.ListIndex = -1
  195.                     End If
  196.  
  197.                 Case 2
  198.                     InDevice = Val(ii)
  199.                     If MidiForm.InList.ListCount > InDevice Then
  200.                         MidiForm.InList.ListIndex = InDevice
  201.                     Else
  202.                         InDevice = -1
  203.                         MidiForm.InList.ListIndex = -1
  204.                     End If
  205.  
  206.             End Select
  207.             jj = jj + 1
  208.         End If
  209.     Loop
  210.  
  211. Midi_LoadIniEnd:
  212.     Close Fnum
  213.     Exit Sub
  214.  
  215. Midi_LoadIniError:
  216.     'Valors per defecte
  217.  
  218.     If MidiForm.OutList.ListCount > 0 Then
  219.         MidiForm.OutList.ListIndex = 0
  220.         OutDevice = -1
  221.     Else
  222.         MidiForm.OutList.ListIndex = -1
  223.         OutDevice = -2
  224.     End If
  225.  
  226.     If MidiForm.InList.ListCount > 0 Then
  227.         MidiForm.InList.ListIndex = 0
  228.         InDevice = 0
  229.     Else
  230.         MidiForm.InList.ListIndex = -1
  231.         InDevice = -1
  232.     End If
  233.  
  234.     Resume Midi_LoadIniEnd
  235. End Sub
  236.  
  237. Sub Midi_SaveIni ()
  238.     Dim Msg As String, ap As String
  239.     Dim Fnum, i
  240.  
  241.     On Error GoTo Midi_SaveIniError
  242.  
  243.     Fnum = FreeFile
  244.  
  245.     ap = App.Path
  246.     If Right$(ap, 1) <> "\" Then ap = ap & "\"
  247.     Open ap & "MTC.INI" For Output As Fnum    'If file doesn't exists it's created
  248.  
  249.     Print #Fnum, "[MidiOut Device]"
  250.     Print #Fnum, "*" & Format$(OutDevice)
  251.     Print #Fnum,
  252.     
  253.     Print #Fnum, "[MidiIn Device]"
  254.     Print #Fnum, "*" & Format$(InDevice)
  255.     Print #Fnum,
  256.  
  257.  
  258. Midi_SaveIniEnd:
  259.     Close Fnum
  260.     Exit Sub
  261.  
  262. Midi_SaveIniError:
  263.     Msg = "'MTC.INI' not created!"
  264.     Dlg_Alert Msg
  265.     Resume Midi_SaveIniEnd
  266.  
  267. End Sub
  268.  
  269. Sub OutList_Click ()
  270.     If OutList.ListIndex > -1 Then
  271.         OutDevice = OutList.ListIndex - 1
  272.         MidiOut_Open (OutDevice)
  273.     End If
  274. End Sub
  275.  
  276.